package dotcom;
import java.util.*;			

public class dotcombust {
	
	private gamehelper helper = new gamehelper();
	private ArrayList<dotcom> dotcomlist	=	new ArrayList<dotcom>();
	private int numofguesses = 0;
	
	
	private void setupgame()
	{
		dotcom one = new dotcom();
		one.setname("pets.com");
		dotcom two = new dotcom();
		two.setname("etoys.com");
		dotcom three = new dotcom();
		three.setname( "go2.com");
		
		dotcomlist.add(one);
		dotcomlist.add(two);
		dotcomlist.add(three);
		
		System.out.println("your goal is to sink three dot coms.");
		System.out.println("pets.com, etoys.com, go2.com");
		System.out.println("try to sink them all in the fewest number of guesses");
		
		for(dotcom dotcomtoset  : dotcomlist)
		{
			ArrayList<String> newlocation = helper.placedotcom(3);
			dotcomtoset.setlocationcells(newlocation);
		}
	}
	
	
	private void startplaying()
	{
		while(!dotcomlist.isEmpty()){
			String userguess = helper.getuserinput("enter a guess");
			checkuserguess(userguess);
		}
	}
	
	
	
	private void checkuserguess(String userguess)
	{
		
		numofguesses++;
		String result = "miss";
		
		for(dotcom dotcomtotest : dotcomlist)
		{
			result = dotcomtotest.checkyourself(userguess);
			
			if(result.equals("hit"))
			{
				break;
			}
			
			if(result.equals("kill"))
			{
				dotcomlist.remove(dotcomtotest);
				break;
			}
		}
		
		System.out.println("result");
		
	}
	
	
	private void finishgame()
	{
		System.out.println("all dot coms are dead! your stock is now worthless");
		
		if(numofguesses <= 18)
		{
			System.out.println("it only took you" + numofguesses + "guesses.");
			System.out.println("you got out before your options sank");
		}
		else
		{
			System.out.println("took you long enough." + numofguesses + "guesses.");
			System.out.println("fish are dancing with your options.");
		}
	}
	
	
	public static void main(String[] args)
	{
		
		dotcombust game = new dotcombust();
		game.setupgame();
		game.startplaying();
		
	}

}
